import Swiper from "swiper";
import { Toast } from "mint-ui";
export default {
    //开启首页banner滚动
    bannerScroll: function () {
        setTimeout(function () {
            var mySwiper = new Swiper(".swiper-container1", {
                autoplay: {
                    disableOnInteraction: false,//增加此属性即可
                    delay: 2500,
                },
                effect: "coverflow",
                grabCursor: true, //设置为true时，鼠标覆盖Swiper时指针会变成抓手形状。
                centeredSlides: true, //true默认显示居中
                slidesPerView: 1.3, //显示模块数量 默认为1
                initialSlide: 2,
                autoHeight: true,
                mousewheelControl: true,
                loop: true,
                coverflow: {
                    rotate: 50, // 旋转的角度
                    stretch: 50, // 拉伸   图片间左右的间距和密集度
                    depth: 50, // 深度   切换图片间上下的间距和密集度
                    modifier: 3, // 修正值 该值越大前面的效果越明显
                    slideShadows: true // 页面阴影效果
                }
            });
        }, 150);
    },
    //开启首页头条滚动
    bannerNewsScroll: function () {
        setTimeout(function () {
            var mySwiper = new Swiper(".swiper-container2", {
                autoplay: {
                    disableOnInteraction: false,//增加此属性即可
                    delay: 2500,
                },
                direction: "vertical",
                mousewheelControl: false,
                autoHeight: true,
                autoplay: true,
                loop: true
            });
        }, 150);

    },
    //房源详情banner初始化
    soureDetail: function () {
        var mySwiper = new Swiper(".swiper-container", {
            direction: "horizontal",
            loop: true,
            speed: 2000,
            pagination: {
                el: ".swiper-pagination"
            },
            autoplayDisableOnInteraction: false
        });
    },
    //判断是手机号还是邮箱号
    checkPhoneNumOrEmailNum: function (account, accountStatus, ifRegister) {
        var checkPhone = /^[0-9]*$/; //数字验证
        var checkEmail = /^\w+@[a-z0-9]+\.[a-z]+$/i; //邮箱校验
        var checkPassword = /^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)])+$)^.{8,16}$/;
        if (ifRegister == 1) {
            if (account.accounts == "") {
                Toast({ message: "账号不能为空！" });
                return false;
            }
            if (account.password == "") {
                Toast({ message: "密码不能为空！" });
                return false;
            }
            if(!checkPassword.test(account.password)){
                Toast({ message: "请输入8-16位数的密码,不能为纯英文、数字、符号！" });
                return false;
            }
            if (account.passwordAgain == "") {
                Toast({ message: "确认密码密码不能为空！" });
                return false;
            }
            if (account.password != account.passwordAgain) {
                Toast({ message: "输入的密码不一致！" });
                return false;
            }
            if (account.code == "") {
                Toast({ message: "验证码不能为空！" });
                return false;
            }
        } else {
            if (account.accounts == "") {
                Toast({ message: "账号不能为空！" });
                return false;
            }
            if (account.password == "") {
                Toast({ message: "密码不能为空！" });
                return false;
            }
            if (account.code == "") {
                Toast({ message: "验证码不能为空！" });
                return false;
            }
        }
        // 判断手机号和邮箱
        if (accountStatus == 0) {
            if (account.accounts.indexOf("@") >= 0) {
                if (!checkEmail.test(account.accounts)) {
                    Toast({ message: "请输入正确的邮箱格式！" });
                    return false;
                } else {
                    account = 'email'
                    return account;
                }
            } else {
                if (!checkPhone.test(account.accounts)) {
                    Toast({ message: "请输入正确的手机格式！" });
                    return false;
                } else {
                    account = 'phone'
                    return account;
                }
            }
            // 只判断手机
        } else if (accountStatus == 1) {
            if (!checkPhone.test(account.accounts)) {
                Toast({ message: "请输入正确的手机格式！" });
                return false;
            } else {
                account = 'phone'
                return account;
            }
            // 只判断邮箱
        } else if (accountStatus == 2) {
            if (!checkEmail.test(account.accounts)) {
                Toast({ message: "请输入正确的邮箱格式！" });
                return false;
            } else {
                account = 'email'
                return account;
            }
        }

    }
}